/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package test1;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Costel
 */
@Entity
@Table(name = "volume", catalog = "adminlocal", schema = "")
@NamedQueries({@NamedQuery(name = "Volume.findAll", query = "SELECT v FROM Volume v"), @NamedQuery(name = "Volume.findById", query = "SELECT v FROM Volume v WHERE v.id = :id"), @NamedQuery(name = "Volume.findByVersion", query = "SELECT v FROM Volume v WHERE v.version = :version"), @NamedQuery(name = "Volume.findByNr", query = "SELECT v FROM Volume v WHERE v.nr = :nr")})
public class Volume implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Long id;
    @Column(name = "VERSION")
    private BigInteger version;
    @Column(name = "nr")
    private String nr;
    @OneToMany(mappedBy = "volumId")
    private List<Titulari> titulariCollection;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "volume")
    private Titulari titulari;

    public Volume() {
    }

    public Volume(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        Long oldId = this.id;
        this.id = id;
        changeSupport.firePropertyChange("id", oldId, id);
    }

    public BigInteger getVersion() {
        return version;
    }

    public void setVersion(BigInteger version) {
        BigInteger oldVersion = this.version;
        this.version = version;
        changeSupport.firePropertyChange("version", oldVersion, version);
    }

    public String getNr() {
        return nr;
    }

    public void setNr(String nr) {
        String oldNr = this.nr;
        this.nr = nr;
        changeSupport.firePropertyChange("nr", oldNr, nr);
    }

    public List<Titulari> getTitulariCollection() {
        return titulariCollection;
    }

    public void setTitulariCollection(List<Titulari> titulariCollection) {
        this.titulariCollection = titulariCollection;
    }

    public Titulari getTitulari() {
        return titulari;
    }

    public void setTitulari(Titulari titulari) {
        this.titulari = titulari;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Volume)) {
            return false;
        }
        Volume other = (Volume) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "test1.Volume[id=" + id + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
